package gui;

import java.awt.*;

public class UnderlinedLabel extends Label {
	private static final long serialVersionUID = 1L;

	public UnderlinedLabel() {
        super();
    }

    public void paint(Graphics g) {
        super.paint(g);

        int x = 0;
        int y = 0;
        int width;
        int height;

        FontMetrics fm = g.getFontMetrics();
        width = fm.stringWidth(getText());
        height = fm.getHeight();

        if (getAlignment() == Label.LEFT)
            x = 0;
        else if (getAlignment() == Label.CENTER)
            x = getBounds().width / 2 - width / 2;
        else if (getAlignment() == Label.RIGHT)
            x = getBounds().width - width ;
        y = getBounds().height / 2 + height / 2 - 4;

        g.drawLine(x + 2, y + 2, x + width + 2, y + 2);
    }

    public void update(Graphics g) {
        paint(g);
    }
}